<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>理解通过Function扩展类型</title>
</head>
<body>
<script>
    Function.prototype.method=function(name,func){
        if(!this.prototype[name]){
            this.prototype[name]=func;
            return this;
        }
    }
    Number.method('integer',function(){
           return Math[this<0?'ceil':'floor'](this);
    });
    console.log((-10/3).integer());
    String.method('trim',function(){
       return this.replace(/^\s+|\s+$/g,'');
    });
    console.log(" abc".trim());
</script>
</body>
</html>